home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLSRC.PAK / DIBBLT32.ASM < prev    next >
Assembly Source File  |  1997-05-06  |  4KB  |  177 lines

  1. ;//---------------------------------------------------------------------------
  2. ;// ObjectWindows
  3. ;// Copyright (c) 1995, 1996 by Borland International, All rights Reserved
  4. ;//
  5. ;//$Revision:   10.2  $
  6. ;//
  7. ;//   DibSpriteBlt8 : 32 Bit Non-GDI SpriteBlt for 8bpp DIBs
  8. ;//   DibCopyBlt8 :   32 Bit Non-GDI CopyBlt for 8bpp DIBs
  9. ;//
  10. ;//---------------------------------------------------------------------------
  11.         .386p
  12.         model   flat
  13.         title   DibBlt32.asm
  14. _TEXT   segment dword public use32 'CODE'
  15. _TEXT   ends
  16. _DATA   segment dword public use32 'DATA'
  17. _DATA   ends
  18. _BSS    segment dword public use32 'BSS'
  19. _BSS    ends
  20.  
  21. DGROUP  group   _BSS,_DATA
  22. _TEXT   segment dword public use32 'CODE'
  23.  
  24. ;//---------------------------------------------------------------------------
  25. ;
  26. ;void WINAPI
  27. ;DibCopyBlt8(uint8 HUGE* dstBits, uint32 width, uint32 height, uint32 dstPitch,
  28. ;           uint8 HUGE* srcBits, uint32 srcPitch);
  29.  
  30. public DibCopyBlt8
  31. DibCopyBlt8 proc near
  32.  
  33. dstBits   EQU [ebp+8]   ; Destination bits surface
  34. wdth      EQU [ebp+12]  ; Bits Width
  35. height    EQU [ebp+16]  ; Bits Height
  36. dstPitch  EQU [ebp+20]  ; Destination scan pitch
  37.  
  38. srcBits   EQU [ebp+24]  ; Source bits surface
  39. srcPitch  EQU [ebp+28]  ; Source scan pitch
  40.  
  41.     push ebp
  42.     mov  ebp,esp
  43.     push esi
  44.     push edi
  45.  
  46.     mov ecx, wdth           ; ECX is Width
  47.     or  ecx,ecx
  48.     jz  DCBComplete         ; No Source Width
  49.  
  50.     mov edx, height         ; EDX is line counter
  51.     or edx,edx
  52.     jz DCBComplete          ; No Source Height
  53.  
  54.     xor esi, esi            ; Clear out ESI
  55.     mov esi, srcBits        ; ESI point to source
  56.  
  57.     xor edi, edi
  58.     mov edi, dstBits        ; EDI point to dest
  59.  
  60.     sub srcPitch, ecx       ; Adjust for width of object.
  61.     sub dstPitch, ecx       ; Adjust for width of object.
  62.  
  63.     mov ebx,ecx
  64.     shr ebx,2
  65.  
  66.     mov eax,ecx
  67.     and eax,11b
  68.  
  69. DCBLoopY:
  70.  
  71.     mov ecx,ebx
  72.     rep movs dword ptr [edi], dword ptr [esi]
  73.     mov ecx,eax
  74.     rep movs byte ptr [edi], byte ptr [esi]
  75.     add esi,srcPitch
  76.     add edi,dstPitch
  77.     dec edx
  78.     jnz short DCBLoopY
  79.  
  80. DCBComplete:
  81.  
  82.     pop edi
  83.     pop esi
  84.     pop ebp
  85.  
  86.     ret 6*4
  87.  
  88. DibCopyBlt8 endp
  89.  
  90. ;//---------------------------------------------------------------------------
  91. ;
  92. ;void WINAPI
  93. ;DibSpriteBlt8(uint8 HUGE* dstBits, uint32 width, uint32 height, uint32 dstPitch,
  94. ;             uint8 HUGE* srcBits, uint32 srcPitch, uint8 transparent);
  95.  
  96. public DibSpriteBlt8
  97. DibSpriteBlt8 proc near
  98.  
  99. dstBits   EQU [ebp+8]   ; Destination bits surface
  100. wdth      EQU [ebp+12]  ; Bits Width
  101. height    EQU [ebp+16]  ; Bits Height
  102. dstPitch  EQU [ebp+20]  ; Destination scan pitch
  103.  
  104. srcBits   EQU [ebp+24]  ; Source bits surface
  105. srcPitch  EQU [ebp+28]  ; Source scan pitch
  106.  
  107. trans     EQU [ebp+32]  ; Transparent color
  108.  
  109.     push ebp
  110.     mov  ebp,esp
  111.  
  112.     push esi
  113.     push edi
  114.     push ebx
  115.  
  116.     mov eax, trans
  117.     mov edx, height
  118.     mov ecx, srcPitch
  119.  
  120.     mov ebx, wdth           ; ECX is Width
  121.     or  ebx,ebx
  122.     jz  DSBComplete         ; No Source Width
  123.  
  124.     xor esi, esi
  125.     mov esi, srcBits        ; ESI point to source
  126.  
  127.     xor edi, edi
  128.     mov edi, dstBits        ; EDI point to dest
  129.  
  130.     sub ecx,ebx             ; Adjust for width of object.
  131.     sub dstPitch,ebx         ; Adjust for width of object.
  132.  
  133. DSBLoopY:
  134.  
  135.     and edx, edx            ; Flag more height.
  136.     jz  DSBComplete         ; Complete if no more height.
  137.  
  138.     mov ebx, wdth           ; ECX is pixel counter
  139.  
  140. DSBLoopX:
  141.  
  142.     mov ah, [esi]           ; Load pixel.
  143.     cmp al, ah              ; Is pixel masked?
  144.     jz  DSBLoopXMasked      ; Yes, jump past move.
  145.  
  146.     mov [edi], ah
  147.  
  148. DSBLoopXMasked:
  149.  
  150.     inc esi                 ; Increment Source.
  151.     inc edi                 ; Increment Destination.
  152.  
  153.     dec ebx                 ; Decrement scan line.
  154.     jnz DSBLoopX            ; Jump to next pixel of scan line.
  155.  
  156. ; move on to the start of the next line
  157.  
  158.     add esi, ecx            ; Adjust to next scan line.
  159.     add edi, dstPitch       ; Adjust to next scan line.
  160.  
  161.     dec edx                 ; line counter
  162.     jmp DSBLoopY            ; Jump back for more height.
  163.  
  164. DSBComplete:
  165.  
  166.     pop ebx
  167.     pop edi
  168.     pop esi
  169.     pop ebp
  170.  
  171.     ret 7*4
  172.  
  173. DibSpriteBlt8 endp
  174.  
  175. _TEXT   ends
  176.         END
  177.